import Request from "@/js/public/request"
import '@/style/comm.css'
import './index.css'
import $ from "jquery"

let mobile = localStorage.getItem("serverZoomMobile10086");
try {
  let star = mobile.substr(3, 4);
  let userLook = mobile.replace(star, "****");
  $("#mobile").val(userLook);
} catch (error) {
    console.log(error)
}

$("#submit").off('click').on("click", function() {
  let userPhone =safeStr($("#mobile").val()) ;
  let userType = safeStr($("#type").val());
  let suggestContent = safeStr($("#suggestContent").val())
  if (userPhone && userType && suggestContent) {
    if (userPhone.substr(3, 4) == "****") {
      userPhone = mobile;
    }
    $.post(Request + "/userFeedbackCtl/submit", {
      loginPhone: mobile,
      feedbackPhone: userPhone,
      serviceName: userType,
      feedbackContent: suggestContent
    },function(data){
      if(data.success){
        alert('提交成功')
        window.location.href='./index.html'
      }else{
        alert('系统繁忙!请稍后重试')
      }
    });
  } else {
    alert("请填写完整");
  }
});

function safeStr(str){
  return str.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g, "&quot;").replace(/'/g, "&#039;");
}
